﻿<navigation:Page x:Class="QSHC.QSchedule.Silverlight.Views.PhysicianAbsentPage" 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           xmlns:vm="clr-namespace:QSHC.QSchedule.Silverlight.ViewModels"
           xmlns:converter="clr-namespace:QSHC.QSchedule.Silverlight.Converters"
           xmlns:custom="clr-namespace:QSHC.CustomControl;assembly=QSHC.CustomControl"
           mc:Ignorable="d" Language="th-TH" FontFamily="Tahoma" FontSize="14"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           d:DesignWidth="970" d:DesignHeight="800" 
           Title="PhysicianAbsentPage" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">
    
    <navigation:Page.Resources>
        <vm:PhysicianAbsentViewModel x:Key="physicianAbsentViewModel" />
        <converter:PhysicianToTextConverter x:Key="physicianToTextConverter" />
        <converter:PhysicianAbsentServiceConverter x:Key="physicianAbsentServiceConverter" />
        <converter:PhysicianAbsentDateConverter x:Key="physicianAbsentDateConverter" />
    </navigation:Page.Resources>
    
    <Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource physicianAbsentViewModel}}">
        <StackPanel Orientation="Horizontal">
            <ListBox Width="250" Margin="5" Style="{StaticResource ListBoxStyle}" ItemsSource="{Binding Path=Physicians}" SelectedItem="{Binding Path=SelectedPhysician, Mode=TwoWay}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding EmployeeCode, Converter={StaticResource physicianToTextConverter}}" />
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
            <StackPanel Orientation="Vertical">
                <StackPanel Orientation="Horizontal">
                    <TextBlock Width="80" TextAlignment="Right" Margin="5" Text="เหตูผล :" Style="{StaticResource TextBlockStyle}" />
                    <TextBox Margin="5" Width="200" Style="{StaticResource TextBoxStyle}" Text="{Binding Path=Reason, Mode=TwoWay}" />
                    <TextBlock Width="80" TextAlignment="Right" Margin="5" Text="หน่วยบริการ :" Style="{StaticResource TextBlockStyle}" />
                    <ComboBox Width="250" Margin="5,0,0,0" ItemsSource="{Binding Path=Services}" DisplayMemberPath="Name" SelectedItem="{Binding Path=SelectedService, Mode=TwoWay}" Style="{StaticResource ComboBoxStyle}" />
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Width="80" TextAlignment="Right" Margin="5" Text="ตั้งแต่ :" Style="{StaticResource TextBlockStyle}" />
                    <custom:ThaiDatePicker Margin="5" SelectedDate="{Binding Mode=TwoWay, Path=BeginDate}" VerticalAlignment="Center" FirstDayOfWeek="Monday" Width="160" />
                    <TextBlock Width="80" TextAlignment="Right" Margin="46,5,5,5" Text="จนถึง :" Style="{StaticResource TextBlockStyle}" />
                    <custom:ThaiDatePicker Margin="5" SelectedDate="{Binding Mode=TwoWay, Path=EndDate}" VerticalAlignment="Center" FirstDayOfWeek="Monday" Width="160" />
                    <Button Content="เพิ่ม" Width="80" Command="{Binding Path=AddCommand}" Style="{StaticResource ButtonStyle}" Margin="5" />
                </StackPanel>
                <sdk:DataGrid Margin="5" AutoGenerateColumns="False" Height="400" Width="700" ItemsSource="{Binding Path=PhysicianAbsents}" SelectedItem="{Binding Path=SelectedPhysicianAbsent, Mode=TwoWay}" FontFamily="Tahoma" FontSize="14">
                    <sdk:DataGrid.Columns>
                        <sdk:DataGridTextColumn Binding="{Binding Path=Reason}" Header="เหตุผล" IsReadOnly="True" />
                        <sdk:DataGridTextColumn Binding="{Binding Converter={StaticResource physicianAbsentServiceConverter}}" Header="หน่วยบริการ" IsReadOnly="True" />
                        <sdk:DataGridTextColumn Binding="{Binding Converter={StaticResource physicianAbsentDateConverter}}" Header="ตั้งแต่" IsReadOnly="True" />
                        <sdk:DataGridTextColumn Binding="{Binding Path=LastEmployeeLog}" Header="User" IsReadOnly="True" />
                        <sdk:DataGridTextColumn Binding="{Binding Path=LastLog.LogDateTime}" Header="Update" IsReadOnly="True" />
                    </sdk:DataGrid.Columns>
                </sdk:DataGrid>
                <Button Content="ลบ" Width="80" Command="{Binding Path=DeleteCommand}" Style="{StaticResource ButtonStyle}" Margin="5" />
            </StackPanel>
        </StackPanel>
    </Grid>
</navigation:Page>
